﻿#ifndef MANGLOBAL_H
#define MANGLOBAL_H

#include <QObject>
#include "src/middle/logs/loggerproxy.h"
#include "src/middle/config/errorcode.h"
#include "src/middle/config/exceptions.h"

#define MG ManGlobal::instance()

#define mLogIns MG->mLog
#define mTotle mLogIns->reset(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).total
#define mDebug mLogIns->reset(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).debug
#define mInfo mLogIns->reset(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).info
#define mWarning mLogIns->reset(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).warning
#define mError mLogIns->reset(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).error
#define mFatal mLogIns->reset(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).fatal

class ManCloud;
class ManDB;
class ManPlugin;
class GateWay;
class ManSignals;
class LoggerProxy;
class ManModels;

/// @brief 单例的全局管理器
///     因为单例对象太多, 干脆只保留一个,
///     用于管理其他单例对象.
class ManGlobal: public QObject
{
    Q_OBJECT
public:
    explicit ManGlobal(QObject* parent = nullptr);
    ~ManGlobal();
    static ManGlobal* instance();
    void init(int argc, char* argv[]);

public:
    LoggerProxy* mLog = nullptr;   // 日志代理
    ManCloud* mCloud = nullptr;    // 对象存储管理
    ManDB* mDb = nullptr;          // 数据库管理
    ManPlugin* mPlugin = nullptr;  // 插件管理
    GateWay* mGate = nullptr;      // 网关管理
    ManSignals* mSignal = nullptr; // 信号管理
    ManModels* mModels = nullptr;  // 模型管理
};

#endif // MANGLOBAL_H
